﻿Option Explicit On

Public Class GlobalCRM
    Private Shared _VirtualCompanyDir As String
    Private Shared _CurrentCaseID As Long
    Private Shared _CurrentCandidateID As Long
    Private Shared _CurrentCandidateName As String
    Private Shared _CurrentContactID As Long
    Private Shared _CurrentCompanyID As Long
    Private Shared _CurrentConID As Long
    Private Shared _CurrentNTUserName As String
    Private Shared _CurrentNTPassword As String
    Private Shared _CurrentPaymentID As Long
    Private Shared _CurrentBranchID As Long
    Private Shared _CreditControllerCaseID, _WrittenOffCaseID As Long
    Private Shared _CurrentCompanyName As String
    Private Shared _CurrentConViewID As Long
    Private Shared _DatePopUpDate As Date
    Private Shared _CurrentDependentParentDescription As String
    Private Shared _CurrentDependentChildDescription As String
    Private Shared _CurrentConName As String
    Public Const SysVersion As Integer = 115
    Public Shared DaysOld As Integer = 90
    Public Shared subj As String = "Global Visas Case Update"
    Public Shared Gbl_Int_Acrobat As Integer
    Private Shared _CurrentSearchType As Integer
    Private Shared _CurrentInvoiceID As Long
    Private Shared _ReportCriteria As ReportCRM.ReportCriteria
    ' Private Shared _ReportCriteriaNew As Reports.ReportCriteria
    Public Shared GLOBALVISA As Microsoft.Win32.RegistryKey = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, "")
    Public Const CUST As String = "Software\Global Visas\Customisation"
    Public Const Reg_CurrentCASEID As String = "Reg_CurrentCASEID"
    Private Shared _HoldReason As String
    Private Shared _HoldExpDate As String
    Public Const COUNTRY_UK = 71
    Public Const COUNTRY_UNKNOWN = 84
    Public Const UKVISA_UNKNOWN = 36
    Public Const UKVISA_NONE = 1

    Public Const OMITLIST As String = "OmitList"
    Public Const DRAFTSAVELOC As String = "DraftSaveLoc"

    Public Const DraftFile As String = "_DraftFile"
    Public Shared ActionCancelled As Boolean = False
    Public Shared TabSelection As enumSelectTab
    Private Shared _QuoteGross As String
    Private Shared _InvNet As String
    Private Shared _InvGross As String
    Private Shared _Payment As String
    Private Shared _Balance As String
    Private Shared _QuoteNet As String

    Public Enum enuSearchType
        eNotSet = 0
        eCompany = 1
        ePerson = 2
        eCase = 3
        eEvent = 4
        eInvoice = 5
    End Enum

    Public Enum enumSelectTab
        eCompany = 0
        ePerson = 1
        eCase = 2
        eEvent = 3
        eAccount = 4

    End Enum
    Public Shared Property CurrentConViewID() As Integer
        'This holds the id of the consultant you are viewing, not the one who is logged in

        Get
            Return _CurrentConViewID
        End Get
        Set(ByVal value As Integer)
            _CurrentConViewID = value

            'frmMDIMain.statPipeline.Text = "Pipline Details for " & CommonSQL.GetConsultantName(value) & " " & CommonSQL.GetPipeline(value)

        End Set
    End Property
    Public Shared Property CurrentPaymentId() As Long
        Get
            Return _CurrentPaymentID
        End Get
        Set(ByVal value As Long)
            _CurrentPaymentID = value
        End Set
    End Property
    Public Shared Property CurrentCaseID() As Long
        Get
            Return _CurrentCaseID
        End Get
        Set(ByVal Value As Long)
            _CurrentCaseID = Value
            If Value > 0 Then
                'CurrentCandidateID = CommonSQL.GetCaseCandidateID(Value)
                'CurrentContactID = Cases.GetCaseContactId(Value)

                'Change the above as some candidate have no company, but the case record does
                _CurrentCandidateID = CommonDataFunctions.GetCaseCandidateID(Value)
                _CurrentCandidateName = CommonDataFunctions.GetCandidateName(_CurrentCandidateID)
                _CurrentContactID = CommonDataFunctions.GetCaseContactId(Value)

                CurrentCompanyID = CommonDataFunctions.GetCaseCompanyId(Value)

            Else
                CurrentCandidateID = 0
                CurrentContactID = 0
            End If
            DebugVariables()
        End Set
    End Property
    Public Shared Property HoldDate() As String

        Get
            Return _HoldExpDate
        End Get
        Set(ByVal value As String)
            _HoldExpDate = value
        End Set
    End Property
    Public Shared Property HoldReason() As String

        Get
            Return _HoldReason
        End Get
        Set(ByVal value As String)
            _HoldReason = value
        End Set
    End Property
    Public Shared Property CurrentSearchType() As Integer
        Get
            Return _CurrentSearchType
        End Get
        Set(ByVal value As Integer)
            _CurrentSearchType = value
        End Set
    End Property
    Public Shared Property CurrentContactID() As Long
        Get
            Return _CurrentContactID
        End Get
        Set(ByVal value As Long)
            _CurrentContactID = value
            DebugVariables()
        End Set
    End Property

    Public Shared Property CurrentInvoiceId() As Long
        Get
            Return _CurrentInvoiceID
        End Get
        Set(ByVal value As Long)
            _CurrentInvoiceID = value
        End Set
    End Property
    Public Shared Property CurrentConID() As Integer
        Get
            Return _CurrentConID
        End Get
        Set(ByVal value As Integer)
            _CurrentConID = value
            _CurrentConViewID = value

            CurrentConName = CommonDataFunctions.GetConsultantName(value)
        End Set
    End Property
    Public Shared Property CurrentNTUserName() As String
        Get
            Return _CurrentNTUserName
        End Get
        Set(ByVal value As String)
            _CurrentNTUserName = value
        End Set
    End Property

    Public Shared Property CurrentNTPassword() As String
        Get
            Return _CurrentNTPassword
        End Get
        Set(ByVal value As String)
            _CurrentNTPassword = value
        End Set
    End Property
    Public Shared Property CurrentConName() As String
        Get
            Return _CurrentConName
        End Get
        Set(ByVal value As String)
            _CurrentConName = value
        End Set
    End Property
    Public Shared Property CurrentCandidateID() As Long
        Get
            Return _CurrentCandidateID
        End Get
        Set(ByVal Value As Long)
            _CurrentCandidateID = Value
            If Value > 0 Then
                CurrentCandidateName = CommonDataFunctions.GetCandidateName(Value)
                CurrentCompanyID = CommonDataFunctions.GetCandidateCompanyID(Value)
            Else
                CurrentCandidateName = String.Empty
                CurrentCompanyID = 0
            End If
            DebugVariables()
        End Set
    End Property

    Public Shared Property CurrentCandidateName() As String
        Get
            Return _CurrentCandidateName
        End Get
        Set(ByVal value As String)
            _CurrentCandidateName = value
        End Set
    End Property
    Public Shared Property CurrentCompanyID() As Long
        Get
            Return _CurrentCompanyID
        End Get
        Set(ByVal value As Long)
            _CurrentCompanyID = value
            'If value > 0 Then
            '    CurrentCompanyName = CommonDataFunctions.GetCompanyName(value)
            'End If

            DebugVariables()
        End Set
    End Property
    Public Shared Property CurrentCompanyName() As String
        Get
            Return _CurrentCompanyName
        End Get
        Set(ByVal value As String)
            _CurrentCompanyName = value
        End Set
    End Property
    Public Shared Property CurrentBranchId() As Long
        Get
            Return _CurrentBranchID
        End Get
        Set(ByVal value As Long)
            _CurrentBranchID = value
        End Set
    End Property

    Public Shared Property CurrentDependentParentDescription() As String
        Get
            Return _CurrentDependentParentDescription
        End Get
        Set(ByVal value As String)
            _CurrentDependentParentDescription = value
        End Set
    End Property

    Public Shared Property CurrentDependentChildDescription() As String
        Get
            Return _CurrentDependentChildDescription
        End Get
        Set(ByVal value As String)
            _CurrentDependentChildDescription = value
        End Set
    End Property

    Public Shared Property CreditControllerCaseID() As Long
        Get
            Return _CreditControllerCaseID
        End Get
        Set(ByVal value As Long)
            _CreditControllerCaseID = value
        End Set
    End Property

    Public Shared Property WrittenOffCaseID() As Long
        Get
            Return _WrittenOffCaseID
        End Get
        Set(ByVal value As Long)
            _WrittenOffCaseID = value
        End Set
    End Property
    Public Shared Sub DebugVariables()
        'frmMDIMain.Text = "CaseId: " & _CurrentCaseID & ",CandidateId: " & _CurrentCandidateID & ",CompanyId: " & _CurrentCompanyID & ",ContactId: " & _CurrentContactID
        Dim UIVariable As String = "CaseId: " & _CurrentCaseID & ",CandidateId: " & _CurrentCandidateID & ",CompanyId: " & _CurrentCompanyID & ",ContactId: " & _CurrentContactID
    End Sub
    Public Shared Property ReportCriteria() As ReportCRM.ReportCriteria
        Get
            Return _ReportCriteria
        End Get
        Set(ByVal value As ReportCRM.ReportCriteria)
            _ReportCriteria = value
        End Set
    End Property
    


    Public Shared Property DatePopUpDate() As Date
        'Stores last value selected from the date pop up form

        Get
            Return _DatePopUpDate
        End Get
        Set(ByVal value As Date)
            _DatePopUpDate = value
        End Set
    End Property

    Public Shared Sub ResetGlobalVars()
        _CurrentCandidateID = 0
        _CurrentCandidateName = String.Empty
        _CurrentCompanyID = 0
        _CurrentCaseID = 0
        _CurrentCompanyName = String.Empty
        _CurrentContactID = 0
        _CurrentInvoiceID = 0
    End Sub
    Public Class LocalAttachments
        'Stores files generated by CRM stored on local PC that will be needed for email attachments

        Public Structure LocalAttachment
            Public Name As String
            Public Filepath As String
            Public Temp As Integer
        End Structure

        Public Shared Attachments As New Collection

        Public Shared Sub AddAttachment(ByVal Filename As String, ByVal FilePath As String, Optional ByVal Temp As Integer = 1)

            Dim myAttach As New LocalAttachment

            With myAttach
                .Name = Filename
                .Filepath = FilePath
                .Temp = Temp
            End With

            Attachments.Add(myAttach)

        End Sub

    End Class
    Public Shared Property QuoteGross() As String

        Get
            Return _QuoteGross
        End Get
        Set(ByVal value As String)
            _QuoteGross = value
        End Set
    End Property
    Public Shared Property InvGross() As String
        Get
            Return _InvGross
        End Get
        Set(ByVal value As String)
            _InvGross = value
        End Set
    End Property
    Public Shared Property Payment() As String
        Get
            Return _Payment
        End Get
        Set(ByVal value As String)
            _Payment = value
        End Set
    End Property
    Public Shared Property Balance() As String
        Get
            Return _Balance
        End Get
        Set(ByVal value As String)
            _Balance = value
        End Set
    End Property
    Public Shared Property QuoteNet() As String
        Get
            Return _QuoteNet
        End Get
        Set(ByVal value As String)
            _QuoteNet = value
        End Set
    End Property
    Public Shared Property InvNet() As String

        Get
            Return _InvNet
        End Get
        Set(ByVal value As String)
            _InvNet = value
        End Set
    End Property
    'Public Shared Property VirtualCompanyDir() As String
    '    Get
    '        Return _VirtualCompanyDir
    '    End Get
    '    Set(ByVal value As String)
    '        _VirtualCompanyDir = value
    '    End Set
    'End Property
End Class

